//
//  ViewController.m
//  Demo0030
//
//  Created by zTercel on 13-3-12.
//  Copyright (c) 2013年 zTercel. All rights reserved.
//

#import "ViewController.h"

@interface ViewController (loginPage)

@end

@implementation ViewController
@synthesize nameField;
@synthesize passwordField;
@synthesize loginButton;

-(IBAction)loginPressed:(id)sender
{
	UIActionSheet* sheet = [[UIActionSheet alloc]initWithTitle:@"Do you login?"
													  delegate:self
											 cancelButtonTitle:@"No,thanks"
										destructiveButtonTitle:@"Yes, i do"
											 otherButtonTitles: nil];
	[sheet showInView:self.view];
	
	return;
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
	const uint KeyCancelButton = 1;
	if (buttonIndex != KeyCancelButton)
	{
		if (!([@"ztercel" isEqualToString:[nameField text]] && [@"123456" isEqualToString:[passwordField text]]))
		{
			 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Alert error"
																 message:@"name or password input error"
																delegate:self
													   cancelButtonTitle:@"Enter"
													   otherButtonTitles:nil];
			[alertView show];
		} else {
			[loginButton setTitle:@"logined" forState:UIControlStateNormal];
		}
	}
}

-(IBAction)nameFieldDoneEditing:(id)sender
{
	[sender resignFirstResponder];
}

-(IBAction)backgroupTap:(id)sender
{
	[nameField resignFirstResponder];
	[passwordField resignFirstResponder];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
	
	
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
